<?php
$socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
socket_set_option($socket,SOL_SOCKET,SO_REUSEADDR,true);
socket_bind($socket,"0.0.0.0","9999");
socket_listen($socket);
while (true){
    $connSock = socket_accept($socket);
    socket_getpeername($connSock,$ip,$port);
    echo "==={$ip}==={$port}==connect===".PHP_EOL;
    while (true){
        $str = socket_read($connSock,1024);
        socket_write($connSock,strtoupper($str));
        echo "来自客户端的内容===".$str.PHP_EOL;
    }
    socket_close($connSock);
}
socket_close($socket);